import { Application } from 'egg';

/**
 * @param {Egg.Application} app - egg application
 */
export default (app: Application) => {
  const { router, controller, passport } = app;
  const jwt = passport.authenticate('jwt', {
    session: false,
    successReturnToOrRedirect: undefined,
  });
  router.get('/', controller.home.index);
  router.post('/user/login', controller.home.userLogin);
  // 下载模版文件
  router.post('/downloadTemplate', jwt, controller.home.downloadTemplate);
  // 获取下拉弹框的选项
  router.get('/global/selections', controller.home.getSelections);
  router.get(
    '/global/organizations',
    controller.home.getOrganizationSelections
  );
  router.get('/global/talents', controller.home.getTalentSelections);


  // organization
  router.get('/financial_list', jwt, controller.financial.getFinancial_list);
  router.post('/update_financial', jwt, controller.financial.updateFinancial);
  router.get('/selectList', jwt, controller.financial.getSelectList);
  router.post('/createFinancial', jwt, controller.financial.createFinancial);
  router.post('/deleteFinancial', jwt, controller.financial.deleteFinancial);
  router.post('/uploadFinancial', jwt, controller.financial.uploadFinancial);
  router.post('/financialFileExist', controller.financial.hasFile);
  router.post('/getMapsw', jwt, controller.financial.getMapsw);
  router.post('/getProductMaps', jwt, controller.product.getProductMaps);
  router.post('/getPatentMaps', jwt, controller.patent.getPatentMaps);
  router.post('/getTalentMaps', jwt, controller.talent.getTalentMaps);
  router.get('/checkFinancial', jwt, controller.financial.checkFinancial);
  router.get('/getOrganizationChart', controller.financial.getOrganizationChart);
  router.get('/getFinancialMap', jwt, controller.financial.getFinancialMap);
  // talent
  router.post('/talent/talentList', jwt, controller.talent.talentList);
  router.post('/talent/insertTalent', jwt, controller.talent.insertTalent);
  router.post('/talent/delTalent', jwt, controller.talent.delTalent);
  router.post('/talent/uploadFiles', jwt, controller.talent.uploadFiles);
  router.post('/talent/update', jwt, controller.talent.update);
  router.post('/talent/hasFile', jwt, controller.talent.hasFile);
  router.post('/talent/hasSameTel', jwt, controller.talent.hasSameTel);
  router.get(
    '/talent/getTalentAttachment',
    controller.talent.getTalentAttachment
  );


  // product
  router.get('/getProductList', jwt, controller.product.getList);
  router.post('/getAllPlace', jwt, controller.product.getAllPlace);
  router.post('/getStatus', jwt, controller.product.getStatus);

  router.post('/uploadProduct', jwt, controller.product.createProduct);
  router.post('/deleteProduct', jwt, controller.product.deleteProduct);
  router.post('/createProduct', jwt, controller.product.createProduct);
  router.post('/uploadProductFiles', jwt, controller.product.getFile);
  router.post('/productFileExist', controller.product.hasFile);
  router.post('/hasProductExist', controller.product.testProductExist);

  router.get('/product/getProductDetail', controller.product.getProductDetail);

  // 专利
  router.get('/patent', controller.patent.list);
  router.get('/checkPatent', controller.patent.checkPatent);
  router.post('/patent', controller.patent.create);
  router.delete('/patent', controller.patent.delete);
  router.get(
    '/patent/getPatentAttachment',
    controller.patent.getPatentAttachment
  );
  router.post('/patent/hasFile', controller.patent.hasFile);
  router.post('/patent/update', controller.patent.update);
  router.post('/uploadPatents', jwt, controller.patent.uploadPatents);

  // talentType
  router.post('/talentType/getList', jwt, controller.talentType.getList);
  router.post('/talentType/insert', jwt, controller.talentType.insert);
  router.post('/talentType/del', jwt, controller.talentType.del);
  router.post('/talentType/haveTalent', jwt, controller.talentType.haveTalent);

  router.get('/platform', jwt, controller.platform.getPlatform);
  // user
  router.post('/user/getInfo', jwt, controller.user.getUserInfo);
  router.post('/user/changeInfo', jwt, controller.user.changeUserInfo);

  router.get('/platform', jwt, controller.platform.getPlatform);
  router.get('/getUserList', jwt, controller.user.getUserList);
  router.post('/deleteUser', jwt, controller.user.deleteUsers);
  router.post('/uploadUser', jwt, controller.user.uploadUser);
  router.post('/createUser', jwt, controller.user.createUser);
  router.post('/freezeUser', jwt, controller.user.freezeUser);
  router.post('/deleteUserById', jwt, controller.user.deleteUser);
  router.post('/user/registered', controller.user.hasSameTel);
  router.post('/user/register', controller.user.registerUser);

  /* router.post('/getProjectFile', jwt, controller.product.getProductFile);
  router.post(
    '/uploadOrganizationFile',
    jwt,
    controller.financial.updateFinancialFile
  );  */
  router.get('/getProjectFile', controller.product.getProductFile);
  router.post(
    '/uploadOrganizationFile',
    jwt,
    controller.financial.updateFinancialFile
  );

  router.get('/getOrganizationFile', controller.financial.getFinancialFile);
  router.get('/areaBar', jwt, controller.chart.getAreaBarData);
  router.get('/conversionStateChart', jwt, controller.chart.getConversionStateChart);
  router.get('/getTotal', jwt, controller.chart.getTotal);

  // talent-statistic
  router.get(
    '/talentStatistic/allTalents',
    jwt,
    controller.talentStatistic.allTalents
  );

  // tourist
  router.get('/tourist/:name', controller.home.touristLogin);
  /**
   * 企业库
   */
  router.post('/getCompanyMap', jwt, controller.company.getCompanyMap);
  router.get('/getCompanyMedication', jwt, controller.company.getCompanyMedication);
  router.post('/getAllCompanyType', jwt, controller.company.getAllCompanyType);
  router.get('/company', jwt, controller.company.showList);
  router.post('/company/insert', jwt, controller.company.insert);
  router.post('/company/update', jwt, controller.company.update);
  router.delete('/company/delete', jwt, controller.company.delete);
  router.delete('/company/bulkDelete', jwt, controller.company.bulkDelete);
  router.post('/company/bulkIncrease', jwt, controller.company.bulkIncrease);
  router.get('/company/medicalList', controller.sys.medicalList);
  router.get('/company/companyTypeList', controller.sys.companyTypeList);
  router.get('/company/mainBusinessList', controller.sys.mainBusinessList);
  router.get('/company/optionList', jwt, controller.sys.optionList);
  router.get('/company/detail', jwt, controller.company.companyDetail);
  router.post('/company/uploadFiles', jwt, controller.company.uploadFiles);

  // 图片上传
  router.post('/image', jwt, controller.product.uploadPicture);
  // 下载图片
  router.get('/image', controller.product.viewPicture);
  // 删除图片
  router.delete('/image/deleteImage', jwt, controller.product.deletePicture);
};
